package Gui;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Point;
import javax.swing.*;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;

import client.LibaryMain;

import Control.UserSubscriber;
import Logic.LoginInfo;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Font;
import java.util.ArrayList;
/**
 * this class implements gui of subscriber window 
 * @author Ron Shenkerman
 * @author Gabi Revah
 * @author Aviad Almog
 * @author Ivan Onyshchenko
 */
public class SubscriberWindow extends JPanel {
	private static final long serialVersionUID = 1L;
	private SubscriberWindow subWin;
	private JTextField textField;
	private UserSubscriber user= null;
	public static EditDetails ed;
	/**
	 * Constructor
	 * @param Name
	 * @param user
	 */
	public  SubscriberWindow(String Name , UserSubscriber user){
				super();
				this.user=user;
				initComponents();
		}
	
	
	 
    /**
	 * this function create instance of Subscriber window gui 
	 */
	public void  initComponents() {
			
		setBackground(new Color(153, 204, 255));
		setSize(1000,710);
		JButton btnLogout = new JButton("Logout");
		btnLogout.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 14));
		btnLogout.setBounds(821, 599, 88, 25);
		btnLogout.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				ArrayList<String> Arr=new ArrayList<String>();
				Arr.add("Logout");
				Arr.add("Subscriber");
				Arr.add(LoginInfo.UserName);
				LibaryMain.chat.handleMessageFromGui(Arr);
				MainScreen.cardLayot.show(MainScreen.card, "Login");
				
			}
		});
		
		JButton btnEditDetails = new JButton("Edit Details");
		btnEditDetails.setBounds(354, 292, 295, 41);
		btnEditDetails.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 15));
		btnEditDetails.addActionListener(new java.awt.event.ActionListener() {     // Login action listener 
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	btnEditDetailsActionPerformed(evt);
            
			}
        });
		
		JButton btnLendingCard = new JButton("Lending Card");
		btnLendingCard.setBounds(354, 236, 295, 41);
		btnLendingCard.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				btnLendingCardActionPerformed(e);
			}
		});
		btnLendingCard.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 15));
		
		JButton btnSearch = new JButton("Search");
		btnSearch.setBounds(354, 344, 295, 41);
		btnSearch.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 15));
		btnSearch.addActionListener(new ActionListener() {
	         public void actionPerformed(java.awt.event.ActionEvent evt) {
	            	btnSearchActionPerformed(evt);
	            
				}
	        });
		
		JLabel lblOblPortal = new JLabel("Welcome Subscriber");
		lblOblPortal.setBounds(71, 50, 286, 23);
		lblOblPortal.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 26));
		setLayout(null);
		add(lblOblPortal);
		add(btnSearch);
		add(btnLendingCard);
		add(btnLogout);
		add(btnEditDetails);
		
		JLabel label = new JLabel("");
		label.setIcon(new ImageIcon(SubscriberWindow.class.getResource("/Gui/images/3d_library.png")));
		label.setBounds(410, 155, 749, 495);
		add(label);
		
	
		
	}



	protected void btnEditDetailsActionPerformed(ActionEvent evt) {
		// TODO Auto-generated method stub
		this.ed = new EditDetails(LoginInfo.UserName, null);
		MainScreen.card.add("EditDetails", this.ed);
		MainScreen.cardLayot.show(MainScreen.card, "EditDetails");
		
	}
	protected void btnLendingCardActionPerformed(ActionEvent e){
		ArrayList<String> arr=new ArrayList<String>();
		arr.add("LendingCard");
		arr.add(LoginInfo.UserName);
		LibaryMain.chat.handleMessageFromGui(arr);
		
	}
	protected void btnSearchActionPerformed(ActionEvent evt) {
		DirectorWindow.roll="SubscriberWindow";
		Search sm= new Search();
		MainScreen.card.add("Search", sm);
		MainScreen.cardLayot.show(MainScreen.card, "Search");

		
	}
}
		